import { BaseWindow } from "../../../component/window/BaseWindow";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { TilePanel } from "../equipment/TilePanel";
import { TreasureShowItemRenderer } from "./TreasureShowItemRenderer";
import { DataProvider } from "../../../../fl/data/DataProvider";
//class TreasureGetItemPanel
    
    export  class TreasureGetItemPanel extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(360, 250);
            title = ObjCreate.createTitleTextField("恭喜你获得了");
            titleHeight = 30;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=ObjCreate.createBg(17, 40, 327, 170, this, ImagesConst.WindowCenterB);
            this._itemListPanel = new TilePanel();
            this._itemListPanel.horizontalGap = 2;
            this._itemListPanel.verticalGap = 2;
            this._itemListPanel.columnWidth = 38;
            this._itemListPanel.rowHeight = 38;
            this._itemListPanel.columnCount = 8;
            this._itemListPanel.rowCount = 4;
            this._itemListPanel.setSize(320, 160);
            this._itemListPanel.setStyle("cellRenderer", TreasureShowItemRenderer);
            this._itemListPanel.move(21, 45);
            addChild(this._itemListPanel);
            var loc2=ObjCreate.createGButton("确定", 150, 213, 60, 25, this);
            loc2.addEventListener(flash.events.MouseEvent.CLICK, this.onCloseBtnClickHandler);
            return;
        }

        public /* override */ update(arg1: Object, ... rest): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=0;
            var loc5=0;
            var loc1=[];
            var loc6=0;
            var loc7=arg1;
            for(loc3 of loc7) 
            {
                loc2 = {"updateAmount": loc3.updateAmount, "itemData": loc3.itemData, "code": loc3.itemData.itemCode};
                loc1.push(loc2);
            }
            loc1.sortOn("code", Array.NUMERIC);
            loc4 = 32 - loc1.length;
            loc5 = 0;
            while (loc5 < loc4) 
            {
                loc1.push(null);
                ++loc5;
            }
            this._itemListPanel.dataProvider = new DataProvider(loc1);
            return;
        }

        /* internal  */onCloseBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            return;
        }

        /* internal */ /* var */_itemListPanel: TilePanel;
    }
